{% extends 'GessehCoreBundle::layout.html.twig' %}

{% block titlecontent %}Stages{% endblock %}

{% block content %}
  <h2>Sessions de stage</h2>
  {% if period_form is not empty %}
    {% form_theme period_form 'GessehCoreBundle:Form:fields.html.twig' %}
    <div>{{ form_errors(period_form) }}</div>
    <form method="post" {{ form_enctype(period_form) }}>
  {% endif %}
  <table>
    <thead>
      <tr>
        <th>Début</th>
        <th>Fin</th>
        <th class="actions">Actions</th>
      </tr>
    </thead>
    <tbody>
      {% for period in periods %}
        {% include period_id == period.id ? 'GessehCoreBundle:PlacementAdmin:editPeriod.html.twig' : 'GessehCoreBundle:PlacementAdmin:indexPeriod.html.twig' %}
      {% else %}
        <tr>
          <td colspan=3>Aucune session à afficher</td>
        </tr>
      {% endfor %}
      {% if period_form is not empty and period_id is empty %}
        {% include 'GessehCoreBundle:PlacementAdmin:editPeriod.html.twig' %}
      {% endif %}
    </tbody>
    <tfoot>
      <tr>
        <td>
          <ul>
            <li><a href="{{ path('GCore_PANewPeriod') }}" title="Ajouter une nouvelle session de stage">Ajouter</a></li>
          </ul>
        </td>
      </tr>
    </tfoot>
  </table>
  {% if period_form is not empty %}</form>{% endif %}

  <h2>Stages</h2>
  {% if placement_form is not empty %}
    {% form_theme placement_form 'GessehCoreBundle:Form:fields.html.twig' %}
    <div>{{ form_errors(placement_form) }}</div>
    <form method="post" {{ form_enctype(placement_form) }}>
  {% endif %}
  <table>
    <thead>
      <tr>
        <th>Session</th>
        <th>Étudiant</th>
        <th>Stage</th>
        {% if kparam('eval_active') == true %}<th class="small">Évalué</th>{% endif %}
        <th class="actions">Actions</th>
      </tr>
    </thead>
    <tbody>
      {% for placement in placements %}
        {% include placement_id == placement.id ? 'GessehCoreBundle:PlacementAdmin:editPlacement.html.twig' : 'GessehCoreBundle:PlacementAdmin:indexPlacement.html.twig' %}
      {% else %}
        <tr>
          <td colspan=4>Aucun stage à afficher</td>
        </tr>
      {% endfor %}
      {% if placement_form is not empty and placement_id is empty %}
        {% include 'GessehCoreBundle:PlacementAdmin:editPlacement.html.twig' %}
      {% endif %}
    </tbody>
    <tfoot>
      <tr>
        <td class="actions">
          <ul>
            <li><a href="{{ path('GCore_PANewPlacement') }}#placement_new" title="Ajouter un nouveau stage">Ajouter</a></li>
          </ul>
        </td>
        <td class="pagination">{{ knp_pagination_render(placements) }}</td>
      </tr>
    </tfoot>
  </table>
  {% if placement_form is not empty %}</form>{% endif %}
{% endblock %}

{% block javascripts %}
  {{ parent() }}
  <script src="{{ asset('bundles/gessehcore/js/confirm.js') }}" type="text/javascript"></script>
{% endblock %}
